package com.zbj.data.jpa.service.impl;

import com.google.common.collect.Lists;
import com.zbj.data.jpa.entity.Student;
import com.zbj.data.jpa.repository.StudentRepository;
import com.zbj.data.jpa.service.StudentService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.persistence.criteria.Predicate;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * StudentServiceImpl
 *
 * @author weigang
 * @create 2017-09-10
 **/
@Service
public class StudentServiceImpl implements StudentService {

	@Autowired
	private StudentRepository studentRepository;

	@Override
	public List<Student> findByName(String name) {
		return studentRepository.findByName(name);
	}

	@Override
	public List<Student> findByNameAndAge(String name, Integer age) {
		return studentRepository.findByNameAndAge(name, age);
	}

	@Override
	public List<Student> findByNameOrAge(String name, Integer age) {
		return studentRepository.findByNameOrAge(name, age);
	}

	@Override
	public List<Student> findByAgeBetween(Integer start, Integer end) {
		return studentRepository.findByAgeBetween(start, end);
	}

	@Override
	public List<Student> findByAgeLessThan(Integer age) {
		return studentRepository.findByAgeLessThan(age);
	}

	@Override
	public List<Student> findByAgeLessThanEqual(Integer age) {
		return studentRepository.findByAgeLessThanEqual(age);
	}

	@Override
	public List<Student> findByAgeGreaterThan(Integer age) {
		return studentRepository.findByAgeGreaterThan(age);
	}

	@Override
	public List<Student> findByAgeGreaterThanEqual(Integer age) {
		return studentRepository.findByAgeGreaterThanEqual(age);
	}

	@Override
	public List<Student> findByCreateDateAfter(Date createDate) {
		return studentRepository.findByCreateDateAfter(createDate);
	}

	@Override
	public List<Student> findByCreateDateBefore(Date createDate) {
		return studentRepository.findByCreateDateBefore(createDate);
	}

	@Override
	public List<Student> findByAgeIsNull() {
		return studentRepository.findByAgeIsNull();
	}

	@Override
	public List<Student> findByAgeNotNull() {
		return studentRepository.findByAgeNotNull();
	}

	@Override
	public List<Student> findByNameLike(String name) {
		return studentRepository.findByNameLike(name);
	}

	@Override
	public List<Student> findByNameNotLike(String name) {
		return studentRepository.findByNameNotLike(name);
	}

	@Override
	public List<Student> findByNameStartingWith(String name) {
		return studentRepository.findByNameStartingWith(name);
	}

	@Override
	public List<Student> findByNameEndingWith(String name) {
		return studentRepository.findByNameEndingWith(name);
	}

	@Override
	public List<Student> findByNameContaining(String name) {
		return studentRepository.findByNameContaining(name);
	}

	@Override
	public List<Student> findByNameOrderByAgeDesc(String name) {
		return studentRepository.findByNameOrderByAgeDesc(name);
	}

	@Override
	public List<Student> findByNameNot(String name) {
		return studentRepository.findByNameNotLike(name);
	}

	@Override
	public List<Student> findByAgeIn(Collection<Integer> ages) {
		return studentRepository.findByAgeIn(ages);
	}

	@Override
	public List<Student> findByAgeNotIn(Collection<Integer> ages) {
		return studentRepository.findByAgeNotIn(ages);
	}

	@Override
	public List<Student> findByNameIgnoreCase(String name) {
		return studentRepository.findByNameIgnoreCase(name);
	}
}
